package cn.edu.cqupt.cxcy.action;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.edu.cqupt.cxcy.dto.TeamImpl;
import cn.edu.cqupt.cxcy.model.Tutor;


/**
 * 主页-【场地预约】
 * @author Dancer-mno
 * @date 2015年10月17日
 */
@SuppressWarnings("serial")
public class TeamTutor extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		HttpSession session = req.getSession();
		List<Object> list = (List<Object>)session.getAttribute("user");
		String pjax_back = "$(function(){$(\"a.turn_pjax[href='team/tutor']\").trigger('click');});";
		if(req.getHeader("x-pjax") == null || req.getHeader("x-pjax").equals("null")) {
			req.setAttribute("pjax_back", pjax_back);
			req.getRequestDispatcher("Tteam.jsp").forward(req, resp);
			return;
		} else if (req.getHeader("x-pjax").equals("true")) {
			TeamImpl teamImpl = new TeamImpl();
			Tutor tutor;
			tutor = teamImpl.tutorInfo((int)list.get(1));
			req.setAttribute("tutorInfo", tutor);
			req.getRequestDispatcher("Ttutor.jsp").forward(req, resp);
			return;
		}
	}
	
	
}
